package com.bw.mvvm_comom.network.inteceptor;


import com.bw.mvvm_comom.utils.SpUtils;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

public class TokenInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();
        String token = SpUtils.readToken();
        Request builder = new Request.Builder()
                .url(request.url())
                .headers(request.headers())
                .addHeader("token",token)
                .post(request.body()).build();
        return chain.proceed(builder);
    }
}
